package com.twu.biblioteca;
import java.util.Scanner;

public class BibliotecaApp {

    public static void  main(String[] args) {
        System.out.println(welcomeText());
        int choice;
        Library library = new Library();
        int logged = library.login();
        if(logged == 1){

            do {
                choice = menuGenerator(1);
                switch(choice){
                    case 1: library.listAllItems("Book");
                            break;
                    case 2: library.reserveItem();
                            break;
                    case 3: library.userMessage();
                            break;
                    case 4: library.listAllItems("Movie");
                            break;
                    case 5: System.out.println("Thank You for visiting Bangalore Public Library");
                            break;
                    default: System.out.println("Select a valid option") ;
                }
            }while(choice != 5);

        }
        else{
            do{
                choice=menuGenerator(0) ;
                switch (choice){
                    case 1 : library.listAllItems("Book");
                             break;
                    case 2 : System.out.println("Please talk to a Librarian. Thank you.");
                             break;
                    case 3 : library.listAllItems("Movie");
                             break;
                    case 4 : System.out.println("Thank You for visiting Bangalore Public Library");
                             break;
                    default: System.out.println("Select a valid option");

                }
            }while(choice != 4);

        }
    }
    public static String welcomeText(){
        return "Welcome to Bangalore Public Library";
    }
    public static int menuGenerator(int logged){
                  if(logged == 1)   {
                    System.out.println("\n1. List all books in the library.\n2. Reserve Book.\n3. Membership Details\n4. List all movies in the library \n5. Exit");
                    Scanner user_input = new Scanner( System.in );
                    return user_input.nextInt();
                  }
                  else{
                      System.out.println("\n1. List all books in the library.\n2. Membership Details\n3. List all movies in the library \n4. Exit");
                      Scanner user_input = new Scanner( System.in );
                      return user_input.nextInt();
                  }

    }

}


